package com.example.gameforum.entity;


import javax.persistence.*;
import java.util.Set;

//收藏
@Entity
public class Favorite {

    @Id
    @Column(name = "id", nullable = false)
    private int id;

    //收藏夹名
    @Column(name = "name")
    private String name;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    //用户多对一
    @ManyToOne(cascade={CascadeType.MERGE,CascadeType.REFRESH},optional=false)//可选属性optional=false,表示author不能为空。
    @JoinColumn(name="user_id")//设置在article表中的关联字段(外键)
    private User fuser;


    //帖子多对多
    @ManyToMany(mappedBy = "pfavorites",fetch=FetchType.EAGER)
    private Set<Post> posts;

}
